package com.aqie.security.demo.controller;

import com.aqie.security.demo.response.Constants;
import lombok.extern.slf4j.Slf4j;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @Function:
 * @Author: aqie
 * @Date: 2019/4/3 10:51
 */
@Controller
@Slf4j
public class HelloController {

    @ResponseBody
    @RequestMapping(value = "hello",method = {RequestMethod.GET})
    public String hello(){
        return Constants.HELLO_WORLD;
    }

    @RequestMapping(value = "hello.html",produces="text/html;charset=UTF-8")
    public String helloView(){
        return "helloView";
    }

    public static void main(String[] args) {
        String encodePwd = new BCryptPasswordEncoder().encode("1234");
        log.info(encodePwd);

        boolean matches = new BCryptPasswordEncoder().matches("1234",
                encodePwd);
        log.info("{}", matches);
        log.info("{}", encodePwd.length());
    }
}
